package com.dada.tiku.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.dada.tiku.dao.mapper.PaperCategoryMapper;
import com.dada.tiku.dao.mapper.TPaperMapper;
import com.dada.tiku.pojo.PaperCategory;
import com.dada.tiku.pojo.PaperCategoryExample;
import com.dada.tiku.pojo.TPaper;
import com.dada.tiku.pojo.TPaperExample;
import com.dada.tiku.pojo.TPaperExample.Criteria;
import com.dada.tiku.service.PaperService;
import com.github.pagehelper.PageHelper;

@Service
public class PaperServiceImpl implements PaperService {
	
	@Autowired
	private TPaperMapper paperMapper;
	

	//查找所有的试卷集合
	public List<TPaper> findAllPaper(Integer start, Integer count) {
		PageHelper.startPage(start, count);
		TPaperExample example = new TPaperExample();
		example.setOrderByClause("id");
		List<TPaper> list = paperMapper.selectByExample(example);
		return list;
	}


	
	public List<TPaper> findListByType(Integer typeid, Integer start, Integer count) {
		PageHelper.startPage(start, count);
		TPaperExample example = new TPaperExample();
		Criteria criteria = example.createCriteria();
		example.setOrderByClause("id");
		criteria.andTypeEqualTo(typeid);
		List<TPaper> list = paperMapper.selectByExample(example);
		return list;
	}
	
	@Autowired
	private PaperCategoryMapper categoryMapper;
	//查询试卷类型列表集合
	public List<PaperCategory> findTypePaperList() {
		PaperCategoryExample example = new PaperCategoryExample();
		List<PaperCategory> list = categoryMapper.selectByExample(example );
		return list;
	}

}
